<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>访客详情</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <div v-if="detail">
          <p class="apply-detail-title">{{ detail.statusTitle }} <span
              v-if="detail.status==2">(驳回理由：{{ detail.reason }})</span></p>
          <p class="apply-detail-title">预约老师: {{ detail.users.realname }}</p>
          <p class="apply-detail-title">预访日期: {{ detail.day }}</p>
<!--          <div class="apply-detail">-->
<!--            <div>-->
<!--              <image-preview :src="detail.itinerary_card" :width="150"/>-->
<!--            </div>-->
<!--          </div>-->
          <div class="apply-detail-user">
            <div class="apply-detail-user-list">
              <span>到访类型:</span>
              <span>{{ detail.style==1?'家长陪餐':'普通访客' }}</span>
            </div>
            <div class="apply-detail-user-list">
              <span>姓名:</span>
              <span>{{ detail.name }}</span>
            </div>
            <div class="apply-detail-user-list">
              <span>身份证号:</span>
              <span>{{ detail.id_number }}</span>
            </div>
            <div class="apply-detail-user-list">
              <span>联系方式:</span>
              <span>{{ detail.mobile_phone }}</span>
            </div>
            <div class="apply-detail-user-list">
              <span>访客车牌:</span>
              <span>{{ detail.license_plate ? detail.license_plate : '无' }}</span>
            </div>
            <div class="apply-detail-user-list">
              <span>身体状况:</span>
              <span>
                {{ detail.health_code }}
                <!--                发热、咳嗽、乏力、咽痛、流涕、腹泻、肌肉酸痛等症状-->
              </span>
            </div>
            <div class="apply-detail-user-list">
              <span>到访事由:</span>
              <span>{{ detail.content }}</span>
            </div>
          </div>
          <div class="apply-detail-user">
            <div class="apply-detail-user-list">
              <span>申请时间:</span>
              <span>{{ detail.create_time }}</span>
            </div>
            <div class="apply-detail-user-list" v-if="detail.status!==3">
              <span>审核时间:</span>
              <span>{{ detail.examine_time }}</span>
            </div>
            <div class="apply-detail-user-list" v-if="detail.status!==3">
              <span>审核人:</span>
              <span>{{ detail.examineuser ? detail.examineuser.realname : '未记录' }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="closePOpup" size="small">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['visible','detailId'], // recruitmentType examine 审核
  components: {},
  data() {
    return {
      dialogVisible: false,
      detail: null,
      statusJson: {
        0: '审核中',
        1: '通过',
        2: '驳回',
        3: '失效'
      }
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.initFn()
      } else {
        this.detail = ''
      }
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    initFn() {
      this.$fetch(this.api.visitor.visit_edit, {id: this.detailId}).then((response) => {
        if (response.code === 0) {
          console.log(response)
          response.vo.statusTitle = this.statusJson[response.vo.status]
          this.detail = response.vo
        } else {
          console.log('请求失败')
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 550px;
  height: 80%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}


.jobTime span {
  padding: 0 10px;
}
.apply-detail img{
  margin-right: 20px;
}
.apply-detail img:last-child{
  margin-right: 0;
}
</style>
